import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class ColIterator {

    public static void main(String[] args) {

        Collection list = new ArrayList();
        list.add("list");
        list.add("list2");
        list.add("list3");
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        for (Object object : list) {
            System.out.println(object);
        }
    }
}